//
//  backpack_B3.m
//  K-Music
//
//  Created by CHUN on 16/1/15.
//  Copyright © 2016年 CHUN. All rights reserved.
//

#import "backpack_B3.h"

#import "liwuCell.h"
#import "liwu.h"

#import "Bag_model.h"

#define rewcellCount 3

@interface backpack_B3 ()<UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout>{
    
    
}
@property(nonatomic,strong)UICollectionView* Bag_CollectionView;


@property (nonatomic ,strong) UITableView *backpack_B3_TableView;

@end

@implementation backpack_B3

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = RGB(241, 241, 241);
    self.navigationItem.title = @"免费保险柜";

    self.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithIcon:@"back" highIcon:@"back" target:self action:@selector(back_back)];
    
    [self creatUI];
}
- (void)back_back
{
    [self.navigationController popViewControllerAnimated:YES];
}
#pragma mark -creatUI-
- (void)creatUI
{
    UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc]init];
    [flowLayout setScrollDirection:UICollectionViewScrollDirectionVertical];
    _Bag_CollectionView=[[UICollectionView alloc]initWithFrame:CGRectMake(0, 0, WIDTH  , HEIGHT-100)collectionViewLayout:flowLayout];
    _Bag_CollectionView.delegate=self;
    _Bag_CollectionView.dataSource=self;
    _Bag_CollectionView.backgroundColor=[UIColor whiteColor];
    [self.view addSubview:_Bag_CollectionView];

    //[self get_Bag];
    
}


-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    return [User_information conversion].Bag_person_Data.count;
}

-(UICollectionViewCell*)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    
    [_Bag_CollectionView registerClass:[liwuCell class] forCellWithReuseIdentifier:@"liwuCell"];
    
    liwuCell*cell=(liwuCell*)[collectionView dequeueReusableCellWithReuseIdentifier:@"liwuCell" forIndexPath:indexPath];
    
    cell.backgroundColor=[UIColor whiteColor];
    Bag_model * mode= [[Bag_model alloc]init];
    mode = [User_information conversion].Bag_person_Data[indexPath.row];
    
    [cell.dt sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@",mode.giftUrl]]];
    cell.my_name.text=[NSString stringWithFormat:@"%@",mode.descriptionD];
    cell.mylabel.text=[NSString stringWithFormat:@"%@",mode.quantity];
    
    return cell;
}

-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
    
    NSLog(@"购买-%ld-",indexPath.row);
    
}

//定义每一个cell大小
-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{
    return CGSizeMake(WIDTH/3-1,150);
}

-(UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section{
    return UIEdgeInsetsMake(0, 0, 0, 0);
}

-(CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section{
    return 1;
}
-(CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section{
    return 1;
}

@end
